#region -- INCLUDES --
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SiteManager;
#endregion

/// <summary>
///Dentist Class
///Contains declration and description of both methods & members of Dentist
/// </summary>
/// <remarks>
///AUTHOR   : KAJAL MANDAL
///DATE     : 5 MAY 2007
/// </remarks>
public class clsDentist
{
    Manager objManager = new Manager(true,"ConnectionString");
    #region -- PRIVATE/PUBLIC MEMBERS -- 

    private Manager _mngr;

    private int _ID;
	public int ID
	{
		get { return _ID;}
		set { _ID = value;}
	}
    
    private int _SPECIALITYID;
	public int SPECIALITYID
	{
		get { return _SPECIALITYID;}
		set { _SPECIALITYID = value;}
	}
    
    //private int _PRIMARYSPECIALITYID;
    //public int PRIMARYSPECIALITYID
    //{
    //    get { return _PRIMARYSPECIALITYID; }
    //    set { _PRIMARYSPECIALITYID = value;}
    //}
    
    private int _SECONDARYSPECIALITYID;
	public int SECONDARYSPECIALITYID
	{
		get { return _SECONDARYSPECIALITYID; }
		set { _SECONDARYSPECIALITYID = value;}
	}
    
	private bool _ABMS_CERTIFICATIONID;
    public bool ABMS_CERTIFICATIONID
	{
		get { return _ABMS_CERTIFICATIONID; }
		set { _ABMS_CERTIFICATIONID = value;}
	}
    
    private string _FNAME;
    public string FNAME
	{
		get { return _FNAME; }
		set { _FNAME = value;}
	}

    private string _PHOTO;
    public string PHOTO
    {
        get { return _PHOTO; }
        set { _PHOTO = value; }
    }
   
    private string _MNAME;
    public string MNAME
	{
		get { return _MNAME; }
		set { _MNAME = value;}
	}

    private string _LNAME;
    public string LNAME
	{
		get { return _LNAME; }
		set { _LNAME = value;}
	}

    private string _EMAIL;
    public string EMAIL
	{
		get { return _EMAIL; }
		set { _EMAIL = value;}
	}

    private string _TITLE;
    public string TITLE
	{
		get { return _TITLE; }
		set { _TITLE = value;}
	}

	private string _PASSWORD;
    public string PASSWORD
	{
		get { return _PASSWORD; }
		set { _PASSWORD = value;}
	}
	
	private string _PHONE;
    public string PHONE
	{
		get { return _PHONE; }
		set { _PHONE = value;}
	}
	
    private string _FAX;
	public string FAX
	{
		get { return _FAX; }
		set { _FAX = value;}
	}
	
    private string _ADDRESS1;
	public string ADDRESS1
	{
		get { return _ADDRESS1; }
		set { _ADDRESS1 = value;}
	}

    private string _ADDRESS2;
    public string ADDRESS2
    {
        get { return _ADDRESS2; }
        set { _ADDRESS2 = value; }
    }

    private string _CITY;
    public string CITY
    {
        get { return _CITY; }
        set { _CITY = value; }
    }

    private string _STATE;
    public string STATE
    {
        get { return _STATE; }
        set { _STATE = value; }
    }

    private string _COUNTRYID;
    public string COUNTRYID
    {
        get { return _COUNTRYID; }
        set { _COUNTRYID = value; }
    }

    private string _LANGUAGES;
    public string LANGUAGES
    {
        get { return _LANGUAGES; }
        set { _LANGUAGES = value; }
    }

    private string _INSURANCEIDS;
    public string INSURANCEIDS
    {
        get { return _INSURANCEIDS; }
        set { _INSURANCEIDS = value; }
    }

    private string _COUNTY;
    public string COUNTY
    {
        get { return _COUNTY; }
        set { _COUNTY = value; }
    }

    private string _ZIPCODE;
    public string ZIPCODE
    {
        get { return _ZIPCODE; }
        set { _ZIPCODE = value; }
    }

    private string _GENDER;
    public string GENDER
    {
        get { return _GENDER; }
        set { _GENDER = value; }
    }

    private int _MEDICALSCHOOL;
    public int MEDICALSCHOOL
    {
        get { return _MEDICALSCHOOL; }
        set { _MEDICALSCHOOL = value; }
    }

    private int _GRADUATIONYEAR;
    public int GRADUATIONYEAR
    {
        get { return _GRADUATIONYEAR; }
        set { _GRADUATIONYEAR = value; }
    }

    private string _HOSPITALNAME;
    public string HOSPITALNAME
    {
        get { return _HOSPITALNAME; }
        set { _HOSPITALNAME = value; }
    }

    private int _MAJORACTIVITYID;
    public int MAJORACTIVITYID
    {
        get { return _MAJORACTIVITYID; }
        set { _MAJORACTIVITYID = value; }
    }

    private string _WEBSITE;
    public string WEBSITE
    {
        get { return _WEBSITE; }
        set { _WEBSITE = value; }
    }

    private string _GROUPPRACTICE;
    public string GROUPPRACTICE
    {
        get { return _GROUPPRACTICE; }
        set { _GROUPPRACTICE = value; }
    }

    private DateTime _REGDATE;
    public DateTime REGDATE
    {
        get { return _REGDATE; }
        set { _REGDATE = value; }
    }

    private bool _ISSUBSCRIBE;
    public bool ISSUBSCRIBE
    {
        get { return _ISSUBSCRIBE; }
        set { _ISSUBSCRIBE = value; }
    }

    private DateTime _SUBSCRIPTIONDATE;
    public DateTime SUBSCRIPTIONDATE
    {
        get { return _SUBSCRIPTIONDATE; }
        set { _SUBSCRIPTIONDATE = value; }
    }

    private string _ADVANCEDTRAINING;
    public string ADVANCEDTRAINING
    {
        get { return _ADVANCEDTRAINING; }
        set { _ADVANCEDTRAINING = value; }
    }

    private string _AWARDS;
    public string AWARDS
    {
        get { return _AWARDS; }
        set { _AWARDS = value; }
    }

    private bool _ACCEPTNEW;
    public bool ACCEPTNEW
    {
        get { return _ACCEPTNEW; }
        set { _ACCEPTNEW = value; }
    }

    private int _COST;
    public int COST
    {
        get { return _COST; }
        set { _COST = value; }
    }

    private bool _AEGD;
    public bool AEGD
    {
        get { return _AEGD; }
        set { _AEGD = value; }
    }

    private bool _SPECIALITYBOARD;
    public bool SPECIALITYBOARD
    {
        get { return _SPECIALITYBOARD; }
        set { _SPECIALITYBOARD = value; }
    }

    private bool _MARKSOFDISTICTION;
    public bool MARKSOFDISTICTION
    {
        get { return _MARKSOFDISTICTION; }
        set { _MARKSOFDISTICTION = value; }
    }

    private bool _ISDELETE;
    public bool ISDELETE
    {
        get { return _ISDELETE; }
        set { _ISDELETE = value; }
    }

    private bool _ISBULK;
    public bool ISBULK
    {
        get { return _ISBULK; }
        set { _ISBULK = value; }
    }

    private bool _HasError;
    public bool HasError //read only
    { get { return _HasError; } }

    private string _ErrorDescription;
    public string ErrorDescription //read only
    { get { return _ErrorDescription; } }


    #endregion
    #region private Members
    private int iUserId = 0;
    private int iDentistId = 0;
    private int iFeaturedocTypeId = 0;
    private int iSpecialityId = 0;

    private int iSubSpecialityId = 0;

    private string sTransactionId = "";
    private string sTransactionDate = "";
    private string sTransactionAmount = "";
    private string sSubscriptionId = "";
    //private string sExpYear = "";
    //private string sExpMonth = "";
    //private string sCardNumber = "";
    private string sSubscriptionType = "";
    private string sPhoto = "";
    private string swebsite = "";
    private string sprof_desc = "";

    private byte[] myimage;
    private byte[] th_docimage;

    #endregion

    #region -- Constructor/Destructor --

    /// <summary>
    /// Create an instanc of Manager Class
    /// </summary>
    /// <remarks>
    /// AUTHOR  : KAJAL MANDAL
    /// DATE    : 5 MAY 2007
    /// </remarks>
    public clsDentist()
    {
        _mngr = new Manager(true,"ConnectionString");
        _ID = 0;
    }

    /// <summary>
    /// Create an instance and load the dentist with references to the Id
    /// </summary>
    /// <param name="intDentistID">Dentist ID</param>
    /// <remarks>
    /// AUTHOR  : KAJAL MANDAL
    /// DATE    : 5 MAY 2007
    /// </remarks>
    public clsDentist(int intDentistID)
    {
        _mngr = new Manager(true,"ConnectionString");
        _ID = 0;
        Load(intDentistID);
    }

    /// <summary>
    /// Create an instance and load the dentist with references to the EMail-Id
    /// </summary>
    /// <param name="strDentistID">Dentist E-Mail ID</param>
    /// <remarks>
    /// AUTHOR  : KAJAL MANDAL
    /// DATE    : 5 MAY 2007
    /// </remarks>
    public clsDentist(string strDentistID)
    {
        _mngr = new Manager(true,"ConnectionString");
        _ID = 0;
        Load(strDentistID);
    }

    /// <summary>
    /// Destroy the manager instance
    /// </summary>
    /// <remarks>
    /// AUTHOR  : KAJAL MANDAL
    /// DATE    : 5 MAY 2007
    /// </remarks>
    ~clsDentist()
    { _mngr = null; }

    #endregion

    #region -- Public Methods --

    /// <summary>
    /// Add a Dentist
    /// </summary>
    /// <remarks>
    /// AUTHOR  : KAJAL MANDAL
    /// DATE    : 5 MAY 2007
    /// </remarks>
    public void Add()
    {
        SqlParameter[] prm = new SqlParameter[38];
        try
        {
            #region -- Parameter Filling --
            prm[0] = new SqlParameter("@SPECIALITYID", SqlDbType.Int);
            prm[0].Value = _SPECIALITYID;            
            prm[1] = new SqlParameter("@SECONDARYSPECIALITYID", SqlDbType.Int);
            prm[1].Value = _SECONDARYSPECIALITYID;
            prm[2] = new SqlParameter("@ABMS_CERTIFICATIONID", SqlDbType.Bit);
            prm[2].Value = _ABMS_CERTIFICATIONID;
            prm[3] = new SqlParameter("@FNAME", SqlDbType.VarChar, 50);
            prm[3].Value = _FNAME;
            prm[4] = new SqlParameter("@MNAME", SqlDbType.VarChar, 50);
            prm[4].Value = _MNAME;
            prm[5] = new SqlParameter("@LNAME", SqlDbType.VarChar, 50);
            prm[5].Value = _LNAME;
            prm[6] = new SqlParameter("@EMAIL", SqlDbType.VarChar, 100);
            prm[6].Value = _EMAIL;
            prm[7] = new SqlParameter("@TITLE", SqlDbType.VarChar, 50);
            prm[7].Value = _TITLE;
            prm[8] = new SqlParameter("@PASSWORD", SqlDbType.VarChar, 15);
            prm[8].Value = _PASSWORD;
            prm[9] = new SqlParameter("@PHONE", SqlDbType.VarChar, 50);
            prm[9].Value = _PHONE;
            prm[10] = new SqlParameter("@FAX", SqlDbType.VarChar, 20);
            prm[10].Value = _FAX;
            prm[11] = new SqlParameter("@ADDRESS1", SqlDbType.VarChar, 200);
            prm[11].Value = _ADDRESS1;
            prm[12] = new SqlParameter("@ADDRESS2", SqlDbType.VarChar, 200);
            prm[12].Value = _ADDRESS2;
            prm[13] = new SqlParameter("@CITY", SqlDbType.VarChar, 50);
            prm[13].Value = _CITY;
            prm[14] = new SqlParameter("@STATE", SqlDbType.VarChar, 2);
            prm[14].Value = _STATE;
            prm[15] = new SqlParameter("@COUNTRYID", SqlDbType.VarChar, 10);
            prm[15].Value = _COUNTRYID;
            prm[16] = new SqlParameter("@LANGUAGES", SqlDbType.VarChar, 200);
            prm[16].Value = _LANGUAGES;
            prm[17] = new SqlParameter("@INSURANCEIDS", SqlDbType.VarChar, 200);
            prm[17].Value = _INSURANCEIDS;
            prm[18] = new SqlParameter("@COUNTY", SqlDbType.VarChar, 100);
            prm[18].Value = _COUNTY;
            prm[19] = new SqlParameter("@ZIPCODE", SqlDbType.VarChar, 10);
            prm[19].Value = _ZIPCODE;
            prm[20] = new SqlParameter("@GENDER", SqlDbType.VarChar, 2);
            prm[20].Value = _GENDER;
            prm[21] = new SqlParameter("@MEDICALSCHOOL", SqlDbType.Int);
            prm[21].Value = _MEDICALSCHOOL;
            prm[22] = new SqlParameter("@GRADUATIONYEAR", SqlDbType.Int);
            prm[22].Value = _GRADUATIONYEAR;
            prm[23] = new SqlParameter("@HOSPITALNAME", SqlDbType.VarChar, 1000);
            prm[23].Value = _HOSPITALNAME;
            prm[24] = new SqlParameter("@MAJORACTIVITYID", SqlDbType.Int);
            prm[24].Value = _MAJORACTIVITYID;
            prm[25] = new SqlParameter("@WEBSITE", SqlDbType.VarChar, 200);
            prm[25].Value = _WEBSITE;
            prm[26] = new SqlParameter("@GROUPPRACTICE", SqlDbType.VarChar, 1000);
            prm[26].Value = _GROUPPRACTICE;
            prm[27] = new SqlParameter("@ISSUBSCRIBE", SqlDbType.Bit);
            prm[27].Value = _ISSUBSCRIBE;
            prm[28] = new SqlParameter("@ADVANCEDTRAINING", SqlDbType.VarChar, 2);
            prm[28].Value = _ADVANCEDTRAINING;
            prm[29] = new SqlParameter("@AWARDS", SqlDbType.VarChar, 500);
            prm[29].Value = _AWARDS;
            prm[30] = new SqlParameter("@ACCEPTNEW", SqlDbType.Bit);
            prm[30].Value = _ACCEPTNEW;
            prm[31] = new SqlParameter("@COST", SqlDbType.TinyInt);
            prm[31].Value = _COST;
            prm[32] = new SqlParameter("@AEGD", SqlDbType.Bit);
            prm[32].Value = _AEGD;
            prm[33] = new SqlParameter("@SPECIALITYBOARD", SqlDbType.Bit);
            prm[33].Value = _SPECIALITYBOARD;
            prm[34] = new SqlParameter("@MARKSOFDISTICTION", SqlDbType.Bit);
            prm[34].Value = _MARKSOFDISTICTION;
            prm[35] = new SqlParameter("@ISDELETE", SqlDbType.Bit);
            prm[35].Value = _ISDELETE;
            prm[36] = new SqlParameter("@ISBULK", SqlDbType.Bit);
            prm[36].Value = _ISBULK;
            prm[37] = new SqlParameter("@Id", SqlDbType.Int);
            prm[37].Value = _ID;
            #endregion

            SqlDataReader rd = _mngr.ExecuteQuery("DENTIST_ADD_EDIT", prm);
            if (rd.Read())
            {
                _ID = Convert.ToInt32(rd["id"]);
                _HasError = false;
                _ErrorDescription = string.Empty;
            }
            else
            {
                _HasError = true;
                _ErrorDescription = "Dentist Addtion Failure!";
            }

            
        }
        catch (Exception ex)
        {
            _HasError = true;
            _ErrorDescription = ex.Message;
        }
        return;
    }

    /// <summary>
    /// Update a Dentist
    /// </summary>
    /// <remarks>
    /// AUTHOR  : KAJAL MANDAL
    /// DATE    : 5 MAY 2007
    /// </remarks>
    public void Update()
    {
        SqlParameter[] prm = new SqlParameter[39];
        try
        {
            #region -- Parameter Filling --
            prm[0] = new SqlParameter("@ID", SqlDbType.Int);
            prm[0].Value = _ID;
            prm[1] = new SqlParameter("@SPECIALITYID", SqlDbType.Int);
            prm[1].Value = _SPECIALITYID;            
            prm[2] = new SqlParameter("@SECONDARYSPECIALITYID", SqlDbType.Int);
            prm[2].Value = _SECONDARYSPECIALITYID;
            prm[3] = new SqlParameter("@ABMS_CERTIFICATIONID", SqlDbType.Bit);
            prm[3].Value = _ABMS_CERTIFICATIONID;
            prm[4] = new SqlParameter("@FNAME", SqlDbType.VarChar, 50);
            prm[4].Value = _FNAME;
            prm[5] = new SqlParameter("@MNAME", SqlDbType.VarChar, 50);
            prm[5].Value = _MNAME;
            prm[6] = new SqlParameter("@LNAME", SqlDbType.VarChar, 50);
            prm[6].Value = _LNAME;
            prm[7] = new SqlParameter("@EMAIL", SqlDbType.VarChar, 100);
            prm[7].Value = _EMAIL;
            prm[8] = new SqlParameter("@TITLE", SqlDbType.VarChar, 50);
            prm[8].Value = _TITLE;
            prm[9] = new SqlParameter("@PASSWORD", SqlDbType.VarChar, 15);
            prm[9].Value = _PASSWORD;
            prm[10] = new SqlParameter("@PHONE", SqlDbType.VarChar, 50);
            prm[10].Value = _PHONE;
            prm[11] = new SqlParameter("@FAX", SqlDbType.VarChar, 20);
            prm[11].Value = _FAX;
            prm[12] = new SqlParameter("@ADDRESS1", SqlDbType.VarChar, 200);
            prm[12].Value = _ADDRESS1;
            prm[13] = new SqlParameter("@ADDRESS2", SqlDbType.VarChar, 200);
            prm[13].Value = _ADDRESS2;
            prm[14] = new SqlParameter("@CITY", SqlDbType.VarChar, 50);
            prm[14].Value = _CITY;
            prm[15] = new SqlParameter("@STATE", SqlDbType.VarChar, 2);
            prm[15].Value = _STATE;
            prm[16] = new SqlParameter("@COUNTRYID", SqlDbType.VarChar, 10);
            prm[16].Value = _COUNTRYID;
            prm[17] = new SqlParameter("@LANGUAGES", SqlDbType.VarChar, 200);
            prm[17].Value = _LANGUAGES;
            prm[18] = new SqlParameter("@INSURANCEIDS", SqlDbType.VarChar, 200);
            prm[18].Value = _INSURANCEIDS;
            prm[19] = new SqlParameter("@COUNTY", SqlDbType.VarChar, 100);
            prm[19].Value = _COUNTY;
            prm[20] = new SqlParameter("@ZIPCODE", SqlDbType.VarChar, 10);
            prm[20].Value = _ZIPCODE;
            prm[21] = new SqlParameter("@GENDER", SqlDbType.VarChar, 2);
            prm[21].Value = _GENDER;
            prm[22] = new SqlParameter("@MEDICALSCHOOL", SqlDbType.Int);
            prm[22].Value = _MEDICALSCHOOL;
            prm[23] = new SqlParameter("@GRADUATIONYEAR", SqlDbType.Int);
            prm[23].Value = _GRADUATIONYEAR;
            prm[24] = new SqlParameter("@HOSPITALNAME", SqlDbType.VarChar, 1000);
            prm[24].Value = _HOSPITALNAME;
            prm[25] = new SqlParameter("@MAJORACTIVITYID", SqlDbType.Int);
            prm[25].Value = _MAJORACTIVITYID;
            prm[26] = new SqlParameter("@WEBSITE", SqlDbType.VarChar, 200);
            prm[26].Value = _WEBSITE;
            prm[27] = new SqlParameter("@GROUPPRACTICE", SqlDbType.VarChar, 1000);
            prm[27].Value = _GROUPPRACTICE;
            prm[28] = new SqlParameter("@ISSUBSCRIBE", SqlDbType.Bit);
            prm[28].Value = _ISSUBSCRIBE;
            prm[29] = new SqlParameter("@ADVANCEDTRAINING", SqlDbType.VarChar, 2);
            prm[29].Value = _ADVANCEDTRAINING;
            prm[30] = new SqlParameter("@AWARDS", SqlDbType.VarChar, 500);
            prm[30].Value = _AWARDS;
            prm[31] = new SqlParameter("@ACCEPTNEW", SqlDbType.Bit);
            prm[31].Value = _ACCEPTNEW;
            prm[32] = new SqlParameter("@COST", SqlDbType.TinyInt);
            prm[32].Value = _COST;
            prm[33] = new SqlParameter("@AEGD", SqlDbType.Bit);
            prm[33].Value = _AEGD;
            prm[34] = new SqlParameter("@SPECIALITYBOARD", SqlDbType.Bit);
            prm[34].Value = _SPECIALITYBOARD;
            prm[35] = new SqlParameter("@MARKSOFDISTICTION", SqlDbType.Bit);
            prm[35].Value = _MARKSOFDISTICTION;
            prm[36] = new SqlParameter("@ISDELETE", SqlDbType.Bit);
            prm[36].Value = _ISDELETE;
            prm[37] = new SqlParameter("@ISBULK", SqlDbType.Bit);
            prm[37].Value = _ISBULK;
            if (_PHOTO == null)
            {
                prm[38] = new SqlParameter("@PHOTO", SqlDbType.VarChar, 100);
                prm[38].Value = "";
            }
            else
            {
                prm[38] = new SqlParameter("@PHOTO", SqlDbType.VarChar, 100);
                prm[38].Value = _PHOTO ;
            }
           
            #endregion
            
            _mngr.ExecuteUpdate("DENTIST_ADD_EDIT", prm);
            if (chechDentistInSub(_ID))
            {
                _mngr.ExecuteScalarQuery("update tbl_dntpremium set photo ='" + _PHOTO + "' where dnt_id ='" + _ID + "'");
            }
            _HasError = false;
            _ErrorDescription = string.Empty;            
        }
        catch (Exception ex)
        {
            _HasError = true;
            _ErrorDescription = ex.Message;
        }

        return;
    }
    private bool chechDentistInSub(int id)
    {

        object objcount = _mngr.ExecuteScalarQuery("select count(dnt_id) from tbl_dntpremium where dnt_id=" + id);
        if (Convert.ToString(objcount) != "0")
        {
            return true;
        }
        else
        {
            return false;

        }
    }

    /// <summary>
    /// Load a Dentist as per Dentist ID
    /// </summary>
    /// <param name="DentistID">Doctor ID</param>
    /// <remarks>
    /// AUTHOR  : KAJAL MANDAL
    /// DATE    : 5 MAY 2007
    /// </remarks>
    public void Load(int DentistID)
    {
        SqlParameter[] prm = new SqlParameter[1];
        prm[0] = new SqlParameter("@ID", SqlDbType.Int);
        prm[0].Value = DentistID;

        SqlDataReader rdr = _mngr.ExecuteQuery("DENTIST_LOAD",prm);
        if (rdr.Read())
        {
            //try
            //{
                #region -- Member Value filling --
                _ID = Convert.ToInt32(rdr["Id"].ToString());
                _SPECIALITYID = Convert.ToInt32(rdr["SpecialityID"].ToString());
                _SECONDARYSPECIALITYID = Convert.ToInt32(rdr["SecondarySpecialityID"].ToString());
                _ABMS_CERTIFICATIONID = Convert.ToBoolean(rdr["Abms_CertificationID"].ToString());
                _FNAME = rdr["FName"].ToString();
                _MNAME = rdr["MName"].ToString();
                _LNAME = rdr["LName"].ToString();
                _EMAIL = rdr["Email"].ToString();
                _TITLE = rdr["Title"].ToString();
                _PASSWORD = rdr["Password"].ToString();
                _PHONE = rdr["Phone"].ToString();
                _FAX = rdr["Fax"].ToString();
                _ADDRESS1 = rdr["Address1"].ToString();
                _ADDRESS2 = rdr["Address2"].ToString();
                _CITY = rdr["City"].ToString();
                _STATE = rdr["State"].ToString();
                _COUNTRYID = rdr["CountryId"].ToString();
                _LANGUAGES = rdr["Languages"].ToString();
                _INSURANCEIDS = rdr["InsuranceIds"].ToString();
                _COUNTY = rdr["County"].ToString();
                _PHOTO = rdr["photo"].ToString();
                _ZIPCODE = rdr["ZipCode"].ToString();
                _GENDER = rdr["Gender"].ToString();
                _MEDICALSCHOOL = Convert.ToInt32(rdr["MedicalSchool"].ToString());
                _GRADUATIONYEAR = Convert.ToInt32(rdr["GraduationYear"].ToString());
                _HOSPITALNAME = rdr["HospitalName"].ToString();
                _MAJORACTIVITYID = Convert.ToInt32(rdr["MajorActivityID"].ToString());
                _WEBSITE = rdr["Website"].ToString();
                _GROUPPRACTICE = rdr["GroupPractice"].ToString();
                _REGDATE = Convert.ToDateTime(rdr["RegDate"].ToString());
                _ISSUBSCRIBE = Convert.ToBoolean(rdr["IsSubscribe"].ToString());
                _ADVANCEDTRAINING = rdr["AdvancedTraining"].ToString();
                _AWARDS = rdr["Awards"].ToString();
                
                _ACCEPTNEW = Convert.ToBoolean(rdr["AcceptNew"]);

                _COST = Convert.ToInt32(rdr["Cost"].ToString());
                _AEGD = Convert.ToBoolean(rdr["AEGD"].ToString());
                _SPECIALITYBOARD = Convert.ToBoolean(rdr["SpecialityBoard"].ToString());
                _MARKSOFDISTICTION = Convert.ToBoolean(rdr["MarksOfDistiction"].ToString());
                _ISDELETE = Convert.ToBoolean(rdr["IsDelete"].ToString());
                _ISBULK = Convert.ToBoolean(rdr["IsBulk"].ToString());
                #endregion
                _HasError = false;
                _ErrorDescription = "";
            //}
            //catch (Exception ex)
            //{
            //    _HasError = true;
            //    _ErrorDescription = ex.Message;
            //}
                rdr.Close();
        }
        else
        {
            _HasError = true;
            _ErrorDescription = "Dentist not found!";
            rdr.Close(); 
        }

        return;
    }

    /// <summary>
    /// Load a Dentist as per Dentist EMail ID
    /// </summary>
    /// <param name="DentistEMailID"></param>
    /// <remarks>
    /// AUTHOR  : KAJAL MANDAL
    /// DATE    : 5 MAY 2007
    /// </remarks>
    public void Load(string DentistEMailID)
    {
        SqlParameter[] prm = new SqlParameter[1];
        prm[0] = new SqlParameter("@EMAIL", SqlDbType.VarChar,100);
        prm[0].Value = DentistEMailID;

        SqlDataReader rdr = _mngr.ExecuteQuery("DENTIST_LOAD", prm);
        if (rdr.Read())
        {
            try
            {
                #region -- Member value filling --
                _ID = Convert.ToInt32(rdr["Id"].ToString());
                _SPECIALITYID = Convert.ToInt32(rdr["SpecialityID"].ToString());
                _SECONDARYSPECIALITYID = Convert.ToInt32(rdr["SecondarySpecialityID"].ToString());
                _ABMS_CERTIFICATIONID = Convert.ToBoolean(rdr["Abms_CertificationID"].ToString());
                _FNAME = rdr["FName"].ToString();
                _MNAME = rdr["MName"].ToString();
                _LNAME = rdr["LName"].ToString();
                _EMAIL = rdr["Email"].ToString();
                _TITLE = rdr["Title"].ToString();
                _PASSWORD = rdr["Password"].ToString();
                _PHONE = rdr["Phone"].ToString();
                _FAX = rdr["Fax"].ToString();
                _ADDRESS1 = rdr["Address1"].ToString();
                _ADDRESS2 = rdr["Address2"].ToString();
                _CITY = rdr["City"].ToString();
                _STATE = rdr["State"].ToString();
                _COUNTRYID = rdr["CountryId"].ToString();
                _LANGUAGES = rdr["Languages"].ToString();
                _INSURANCEIDS = rdr["InsuranceIds"].ToString();
                _COUNTY = rdr["County"].ToString();
                _ZIPCODE = rdr["ZipCode"].ToString();
                _GENDER = rdr["Gender"].ToString();
                _MEDICALSCHOOL = Convert.ToInt32(rdr["MedicalSchool"].ToString());
                _GRADUATIONYEAR = Convert.ToInt32(rdr["GraduationYear"].ToString());
                _HOSPITALNAME = rdr["HospitalName"].ToString();
                _MAJORACTIVITYID = Convert.ToInt32(rdr["MajorActivityID"].ToString());
                _WEBSITE = rdr["Website"].ToString();
                _GROUPPRACTICE = rdr["GroupPractice"].ToString();
                _REGDATE = Convert.ToDateTime(rdr["RegDate"].ToString());
                _ISSUBSCRIBE = Convert.ToBoolean(rdr["IsSubscribe"].ToString());

                if (rdr["SubscriptionDate"].ToString().Length>0)
                {
                    _SUBSCRIPTIONDATE = Convert.ToDateTime(rdr["SubscriptionDate"].ToString());
                }

                _ADVANCEDTRAINING = rdr["AdvancedTraining"].ToString();
                _AWARDS = rdr["Awards"].ToString();
                _ACCEPTNEW = Convert.ToBoolean(rdr["AcceptNew"].ToString());
                _COST = Convert.ToInt32(rdr["Cost"].ToString());
                _AEGD = Convert.ToBoolean(rdr["AEGD"].ToString());
                _SPECIALITYBOARD = Convert.ToBoolean(rdr["SpecialityBoard"].ToString());
                _MARKSOFDISTICTION = Convert.ToBoolean(rdr["MarksOfDistiction"].ToString());
                _ISDELETE = Convert.ToBoolean(rdr["IsDelete"].ToString());
                _ISBULK = Convert.ToBoolean(rdr["IsBulk"].ToString());
                #endregion

                _HasError = false;
                _ErrorDescription = "";
                rdr.Close();
            }
            catch (Exception ex)
            {
                rdr.Close();
                _HasError = true;
                _ErrorDescription = ex.Message;
            }
        }
        else
        {
            rdr.Close();
            _HasError = true;
            _ErrorDescription = "Dentist not found!";
        }
        return;
    }

    /// <summary>
    /// Delete a Dentist
    /// </summary>
    /// <remarks>
    /// AUTHOR  : KAJAL MANDAL
    /// DATE    : 5 MAY 2007
    /// </remarks>
    public void Delete()
    { 

    }

    #endregion
    

    public int addtomydentist()
    {
        int iresult = 0;
        try
        {
            SqlParameter[] sqlparam = new SqlParameter[4];
            sqlparam[0] = new SqlParameter("@SNO", SqlDbType.BigInt);
            sqlparam[0].Value = 0;
            sqlparam[1] = new SqlParameter("@UserID ", iUserId);
            sqlparam[2] = new SqlParameter("@DentistId", iDentistId);
            sqlparam[3] = new SqlParameter("@Result", SqlDbType.BigInt);
            sqlparam[3].Direction = ParameterDirection.Output;
            objManager.ExecuteUpdate("[AddToMyDentist]", sqlparam);
            return Convert.ToInt32(sqlparam[3].Value);

        }
        catch (Exception ex)
        {
            HttpContext.Current.Response.Write(ex.Message.ToString());

        }
        return iresult;
    }
    
  
    #region Property
    /// <summary>
    /// Public Property 
    /// </summary>
    public int UserId
    {
        get { return iUserId; }
        set { iUserId = value; }

    }
    public int DentistId
    {
        get { return iDentistId; }
        set { iDentistId = value; }

    }
    public string TransactionId
    {
        get { return sTransactionId; }
        set { sTransactionId = value; }

    }
    public string TransactionDate
    {
        get { return sTransactionDate; }
        set { sTransactionDate = value; }

    }
    public string TransactionAmount
    {
        get { return sTransactionAmount; }
        set { sTransactionAmount = value; }

    }

    public string SubscriptionId
    {
        get { return sSubscriptionId; }
        set { sSubscriptionId = value; }

    }
    public string SubscriptionType
    {
        get { return sSubscriptionType; }
        set { sSubscriptionType = value; }

    }
    public int FeaturedocTypeId
    {
        get { return iFeaturedocTypeId; }
        set { iFeaturedocTypeId = value; }

    }
    public int SpecialityId
    {
        get { return iSpecialityId; }
        set { iSpecialityId = value; }

    }

    public int SubSpecialityId
    {
        get { return iSubSpecialityId; }
        set { iSubSpecialityId = value; }

    }

    public byte[] image
    {
        get { return myimage; }
        set { myimage = value; }

    }

    public byte[] th_image
    {
        get { return th_docimage; }
        set { th_docimage = value; }

    }

    // public string CardNumber
    //{
    //    get { return sCardNumber; }
    //    set { sCardNumber = value; }

    //}
    // public string ExpMonth
    //{
    //    get { return sExpMonth; }
    //    set { sExpMonth = value; }

    //}
    // public string ExpYear
    //{
    //    get { return sExpYear; }
    //    set { sExpYear = value; }

    //}
    private int iUserType = 0;
    private int iLoginID = 0;
    private string sCouponCode = "";
    public int UserType
    {
        get { return iUserType; }
        set { iUserType = value; }

    }
    public int LoginID
    {
        get { return iLoginID; }
        set { iLoginID = value; }

    }
    public string CouponCode
    {
        get { return sCouponCode; }
        set { sCouponCode = value; }

    }
    public string photo
    {
        get { return sPhoto; }
        set { sPhoto = value; }
    }
    public string website
    {
        get { return swebsite; }
        set { swebsite = value; }
    }
    public string prof_desc
    {
        get { return sprof_desc; }
        set { sprof_desc = value; }
    }



    #endregion
    public DataSet GetMydentistByUserId(int Userid)
    {

     SqlParameter[] _SqlparameterObject = null;
    _SqlparameterObject = new SqlParameter[1];
    _SqlparameterObject[0] = new SqlParameter("@UserId", Userid);
    DataSet ds = objManager.ExecuteQuery("[GetMyDentistsByUserId]", _SqlparameterObject, "tblMyDent");
    return ds;
        
       
    }
    public System.Data.DataSet GetMyRatingDenByUserId(int Userid)
    {

        SqlParameter[] _SqlparameterObject = null;

        try
        {
            _SqlparameterObject = new SqlParameter[1];
            _SqlparameterObject[0] = new SqlParameter("@UserId", Userid);
            DataSet ds = objManager.ExecuteQuery("[GetMyRatingDenByUserId]", _SqlparameterObject, "tblMyDoc");

            return ds;
        }
        catch (Exception ex)
        {

            throw (ex);
        }
        finally
        {

            _SqlparameterObject = null;
        }
    }
    /// <summary>
    ///  This function is use for delete a dentist from
    ///  my dentst list 
    /// </summary>
    /// <author>Vinayak Singh Rathore</author>
    /// <date>29 Sep, 2007</date>
    /// <param name="pDoctorID">int</param>
    public string DeleteMyDentist(int pDentistID)
    {
        Manager objManager = new Manager(true,"ConnectionString");
        SqlParameter[] objSqlParameter = new SqlParameter[3];
        objSqlParameter[0] = new SqlParameter("@DentistID", SqlDbType.BigInt);
        objSqlParameter[0].Value = pDentistID;
        objSqlParameter[1] = new SqlParameter("@IsError", SqlDbType.Bit);
        objSqlParameter[1].Direction = ParameterDirection.Output;
        objSqlParameter[2] = new SqlParameter("UserID", SqlDbType.BigInt);
        objSqlParameter[2].Value = Convert.ToInt32(HttpContext.Current.Session["UserId"]);
        objManager.ExecuteQuery("DeleteMyDentist", objSqlParameter);
        if (Convert.ToBoolean(objSqlParameter[1].Value))
        {
            objManager = null;
            return "Dentist can not delete from my dentist list";
        }
        else
        {
            objManager = null;
            return "Dentist has been deleted from my dentist list";
        }
    }
    public int InsertDentistSubscription()
    {
        int iresult = 0;
        try
        {
            SqlParameter[] sqlparam = new SqlParameter[14];
            sqlparam[0] = new SqlParameter("@Id", SqlDbType.BigInt);
            sqlparam[0].Value = 0;
            sqlparam[1] = new SqlParameter("@DentistId ", iDentistId);
            sqlparam[2] = new SqlParameter("@TransactionId", sTransactionId);
            sqlparam[3] = new SqlParameter("@TransactionDate", sTransactionDate);
            sqlparam[4] = new SqlParameter("@TransactionAmount", sTransactionAmount);
            sqlparam[5] = new SqlParameter("@SubscriptionId", sSubscriptionId);
            sqlparam[6] = new SqlParameter("@SubscriptionType", sSubscriptionType);
            sqlparam[7] = new SqlParameter("@FeaturedocTypeId", iFeaturedocTypeId);
            sqlparam[8] = new SqlParameter("@SpecialityId", iSpecialityId);
            sqlparam[9] = new SqlParameter("@photo", sPhoto);
            sqlparam[10] = new SqlParameter("@website", swebsite);
            sqlparam[11] = new SqlParameter("@prof_desc", sprof_desc);
            //sqlparam[9] = new SqlParameter("@CardNumber", sCardNumber);
            //sqlparam[10] = new SqlParameter("@ExpMonth", sExpMonth);
            //sqlparam[11] = new SqlParameter("@ExpYear", sExpYear);
            sqlparam[12] = new SqlParameter("@Result", SqlDbType.BigInt);
            sqlparam[12].Direction = ParameterDirection.Output;

            sqlparam[13] = new SqlParameter("@SubSpecialityId", iSubSpecialityId);
            //sqlparam[14] = new SqlParameter("@Image", myimage);
            //sqlparam[15] = new SqlParameter("@th_Image", th_docimage);

            objManager.ExecuteUpdate("[InsertDentistSubscription]", sqlparam);
            return Convert.ToInt32(sqlparam[12].Value);

        }
        catch (Exception ex)
        {
            HttpContext.Current.Response.Write(ex.Message.ToString());

        }
        return iresult;
    }

    public int UpdateDentistSubscription()
    {
        int iresult = 0;
        try
        {
            SqlParameter[] sqlparam = new SqlParameter[7];
            sqlparam[0] = new SqlParameter("@DentistId ", iDentistId);
            sqlparam[1] = new SqlParameter("@photo", sPhoto);
            sqlparam[2] = new SqlParameter("@website", swebsite);
            sqlparam[3] = new SqlParameter("@prof_desc", sprof_desc);
            sqlparam[4] = new SqlParameter("@Result", SqlDbType.BigInt);
            sqlparam[4].Direction = ParameterDirection.Output;
            //commented at 05/03/2008 by ranjeet to save image into file

            sqlparam[5] = new SqlParameter("@Image", myimage);
            sqlparam[6] = new SqlParameter("@th_Image", th_docimage);

            //commented end
            objManager.ExecuteUpdate("[UpdateDentistSubscription]", sqlparam);
            return Convert.ToInt32(sqlparam[4].Value);

        }
        catch (Exception ex)
        {
            HttpContext.Current.Response.Write(ex.Message.ToString());

        }
        return iresult;
    }

    public bool CheckCouponCode()
    {
        bool iresult = false;
        try
        {
            SqlParameter[] sqlparam = new SqlParameter[4];
            sqlparam[0] = new SqlParameter("@CouponCode", sCouponCode);
            sqlparam[1] = new SqlParameter("@Type ", iUserType);
            sqlparam[2] = new SqlParameter("@ID", iLoginID);
            sqlparam[3] = new SqlParameter("@IsExist", SqlDbType.Bit);
            sqlparam[3].Direction = ParameterDirection.Output;
            objManager.ExecuteUpdate("[CheckCouponCode]", sqlparam);
            return Convert.ToBoolean(sqlparam[3].Value);

        }
        catch (Exception ex)
        {
            HttpContext.Current.Response.Write(ex.Message.ToString());

        }
        return iresult;
    }

    /// <summary>
    /// Authenticate the credentials provided for a Dentist login
    /// Author: 
    /// Implemented By: Deepak
    /// Date: 18th Feb 2008
    /// </summary>
    /// <param name="email">Email of Dentist</param>
    /// <param name="pass">Password</param>
    /// <param name="extraPath">extraPath is obsolete in current scenario, pass 'dentist/' or empty string</param>
    /// <returns>Error message if login False, else redirects to the Dentist content page</returns>
    /// <remarks>
    /// Following session varibles are set on authentication:
    /// userID, LoginName, UserEmail
    /// userType = "Doctor"
    /// DoctorType = "Dentist"
    /// </remarks>
    public string DoDentistLogin(string email, string pass, string extraPath)
    {
        if (email.Trim().Length == 0 || pass.Length == 0)
        {
            return "Invalid Login";
        }

        objManager = new Manager(true,"ConnectionString");
        string strSql = "select id,fname,lname,password from tbl_dentists where email='" + objManager.FixQuote(email) + "' and isdelete=0";
        SqlDataReader sqlDr = objManager.ExecuteQuery(strSql);
        if (sqlDr.Read())
        {
            if (string.Compare(sqlDr["password"].ToString(), pass, false) == 0)
            {
                HttpContext.Current.Session["userID"] = sqlDr["id"].ToString();
                HttpContext.Current.Session["userType"] = "Doctor";
                HttpContext.Current.Session["LoginName"] = sqlDr["fname"].ToString() + " " + sqlDr["lname"].ToString();
                HttpContext.Current.Session["UserEmail"] = email;
                HttpContext.Current.Session["DoctorType"] = "Dentist";
                sqlDr.Close();

                if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["fromPg"]))
                    HttpContext.Current.Response.Redirect(HttpContext.Current.Request.QueryString["fromPg"]);
                else
                    if (extraPath != "NOREDIRECT")
                    {
                        localFunction obj = new localFunction();
                        obj.GetDentInfo(true);
                        //HttpContext.Current.Response.Redirect("../dentist/dentistContent.aspx");
                    }
            }
            else
            {
                sqlDr.Close();
                HttpContext.Current.Session["ShowLayer"] = "True";
                return "Your password is incorrect. Please try again.";
            }
        }
        else
        {
            sqlDr.Close();
            HttpContext.Current.Session["ShowLayer"] = "True";
            return "Incorrect EMAIL ID or PASSWORD. Please try again.";
        }
        return "";
    }
}
